<extend name="Public:base" />
<!--header end-->
<block name="title">
	<title>地址管理</title>
</block>


<block name="css">
	<link rel="stylesheet" href="__PUBLIC__css/address.css" />

</block>

<block name="js">
	<script>var bgurl = "__ROOT__/Public/Home/";</script>
	<script type="text/javascript" src="__PUBLIC__js/address1.js"></script>
	<script type="text/javascript" src="__PUBLIC__js/nav_logo.js"></script>
	<script src="__CITY__jquery.cityselect.js"></script>
	<script src="__LAYER__/layer.js"></script>
	<script>
		$(document).ready(function () {
			$("#city_4").citySelect({
				prov: "广东",
				city: "广州",
				dist: "天河区",
				nodata: "none",
				url:"__CITY__city.min.js",
			});

			$("#city_5").citySelect({
				prov: "广东",
				city: "广州",
				dist: "天河区",
				nodata: "none",
				url:"__CITY__city.min.js",
			});

			var touchMark = false;

			$(".change_addr").click(function () {
				touchMark = true;
				$(".addr_nav li").eq(1).click();

				var cur = $(this).closest("li").index();
				var ps = $("#addr_list li").eq(cur).find("p");

				//获取
				var id = $("#addr_list li ").eq(cur).find(":submit").attr('addr_id');
				var username = ps.eq(0).find("span").eq(0).text();
				var prov = ps.eq(1).find("span").eq(0).text();
				var city = ps.eq(1).find("span").eq(1).text();
				var dist = ps.eq(1).find("span").eq(2).text();
				var address = ps.eq(1).find("span").eq(3).text();
				var code = ps.eq(2).find("span").eq(0).text();
				var mobile = ps.eq(3).find("span").eq(0).text();
//				console.log(name,prov,city,dist,address,code,mobile);

				//修改
				$("#change_form input[name='id']").val(id);
				$("#change_form input[name='username']").val(username);
				$("#change_form  input[name='code']").val(code);
				$("#change_form  input[name='mobile']").val(mobile);

				$("#city_4").citySelect({
					prov: prov,
					city: city,
					dist: dist,
					nodata: "none",
					url:"__CITY__city.min.js",
				});
				$("#change_form  textarea[name='address']").val(address);

			});//.channge_addr click end

			$(".addr_nav li").click(function () {
				if(!$(this).hasClass("active")){
					if($(this).index() == 1 && touchMark == false){
						layer.msg('修改请点击地址下方【修改】按钮', {
							btn: ['知道了']
						});
						return false;
					}else if($(this).index() == 0){
						touchMark = false;
					}
					$(this).addClass("active").siblings().removeClass("active");
					var $curDiv = $(".addr_panels > div").eq($(this).index());
					$curDiv.css({"display":"block"});
					$curDiv.siblings("div").css({"display":"none"});
					$curDiv.find("textarea").val('');
					$curDiv.find(":text").val('');
					$curDiv.find(":hidden").val('');
				}
			})

			$("#change_form").submit(function () {
//				return false;
			})

		})//ready end
	</script>

</block>


<block name="body">

		<!--content-->

		<div class="content">

			<div class="container">

				<!--menu组件-->
				{:W('Index/menu',array('logo_02.png'))}

				<div class="address_text">



						<h4>常用地址</h4>
						<form id="default_addr_form" action="{:U('set_default_addr')}" method="post">
						<div class="information">
							<ul id="addr_list">
								<volist name="address_list" id="vo">
									<li>

										<div style="position: relative" style="overflow: auto" class="place_message <eq name="vo.id" value="$default_id">  default_massage  </eq>">
										<eq name="vo.id" value="$default_id"><span class="def_addr_icon">默认收货地址</span></eq>
											<p>收货人：<span>{$vo.username}</span></p>

											<p>所在地区：<span>{$vo.prov}</span> <span>{$vo.city}</span> <span>{$vo.dist}</span> <span>{$vo.address}</span></p>

											<p >邮编：<span>{$vo.code}</span></p>

											<p>电话：<span>{$vo.mobile}</span></p>

										</div>
										<a   href="{:U('del_addr',array('id'=>$vo['id']))}"   onclick="return confirm('确定要删除该地址吗')" style="display:inline-block; margin-left:0;margin-top: 0px;width: 47px"  class="setup del_addr" >删除</a>
										<a   href="javascript:void(0);"  style="display:inline-block; margin-left:0;margin-top: 0px;width: 47px"  class="setup change_addr"  >修改</a>
										<input addr_id="{$vo.id}" style="position:relative;top:1px; margin-left:0;margin-top: 0px;width: 98px" type="submit" class="setup" value="设为默认地址" >
									</li>
								</volist>
                            <input name="id" type="hidden" value="0">
							</ul>
						</div>
						</form>


						<div class="new_address">


							<ul class="nav nav-pills addr_nav">
								<li role="presentation" class="active"><a href="javascript:void(0);">新增地址</a></li>
								<li role="presentation"><a href="javascript:void(0);">修改地址</a></li>
							</ul>
							<div class="addr_panels">
								<div>
									<form name="add_form" action="{:U()}" class="form-horizontal" method="post">
										<div style="margin: 0" class="row">

											<div class="form-group col-sm-5 col-xs-12">
												<p>所在地区</p>

												<div id = "city_5">
													<select class="prov" name="prov"></select>
													<select class="city" name="city"></select>
													<select class="dist" name="dist"></select>
												</div>

												<p>详细地址</p>

												<textarea name="address" type="text" class="form-control" rows="4"></textarea>

											</div>

											<div class="col-sm-4 col-xs-12">

												<p>邮政编码</p>

												<input name="code" type="text" class="form-control" />

												<p>收货人姓名</p>

												<input name="username" type="text" class="form-control" />

												<p>手机号码</p>

												<input name="mobile" type="text" class="form-control" />

											</div>

											<div class="col-sm-3 col-xs-12">

												<input class="save" type="submit" value="保存">

											</div>

										</div>

									</form>
								</div>
								<div style="display: none">
									<form id="change_form" name="change_form" action="{:U('change_addr')}" class="form-horizontal" method="post">

										<div style="margin: 0" class="row">

											<div class="form-group col-sm-5 col-xs-12">
												<p>所在地区</p>

												<div id = "city_4">
													<select class="prov" name="prov"></select>
													<select class="city" name="city"></select>
													<select class="dist" name="dist"></select>
												</div>

												<p>详细地址</p>

												<textarea name="address" type="text" class="form-control" rows="4"></textarea>

											</div>

											<div class="col-sm-4 col-xs-12">

												<p>邮政编码</p>

												<input name="code" type="text" class="form-control" />

												<p>收货人姓名</p>

												<input name="username" type="text" class="form-control" />

												<p>手机号码</p>

												<input name="mobile" type="text" class="form-control" />

											</div>

											<div class="col-sm-3 col-xs-12">
												<input name="id" type="hidden">
												<input class="save" type="submit" value="修改">

											</div>

										</div>

									</form>
								</div>
							</div>

						</div>
			</div>

			</div>
		</div>

		<!--content end-->
</block>




